package dcutils;

/**
 * Implementations are passed into functions which require a response provided by the user.<br/>
 * E.g.:
<pre style='color:#d1d1d1;background:#000000;'>
new Lambda&lt;Double,Integer>() <span style='color:#b060b0; '>{</span>
    <span style='color:#9999a9; '>// Returns half of the integer value.</span>
    <span style='color:#e66170; font-weight:bold; '>public</span> <span style='color:#bb7977; font-weight:bold; '>Double</span> apply<span style='color:#d2cd86; '>(</span><span style='color:#bb7977; font-weight:bold; '>Integer</span> param<span style='color:#d2cd86; '>)</span> <span style='color:#e66170; font-weight:bold; '>throws</span> <span style='color:#bb7977; font-weight:bold; '>IllegalArgumentException</span> <span style='color:#b060b0; '>{</span>
       <span style='color:#e66170; font-weight:bold; '>if</span><span style='color:#d2cd86; '>(</span><span style='color:#e66170; font-weight:bold; '>null</span> <span style='color:#d2cd86; '>!</span><span style='color:#d2cd86; '>=</span> param<span style='color:#d2cd86; '>)</span> <span style='color:#b060b0; '>{</span>
          <span style='color:#e66170; font-weight:bold; '>return</span> param <span style='color:#d2cd86; '>/</span> 2d<span style='color:#b060b0; '>;</span>
       <span style='color:#b060b0; '>}</span> <span style='color:#e66170; font-weight:bold; '>else</span> <span style='color:#b060b0; '>{</span>
          <span style='color:#e66170; font-weight:bold; '>return</span> <span style='color:#e66170; font-weight:bold; '>new</span> <span style='color:#bb7977; font-weight:bold; '>IllegalArgumentException</span><span style='color:#d2cd86; '>(</span><span style='color:#00c4c4; '>"param cannot be null."</span><span style='color:#d2cd86; '>)</span><span style='color:#b060b0; '>;</span>
       <span style='color:#b060b0; '>}</span>
    <span style='color:#b060b0; '>}</span>
 <span style='color:#b060b0; '>}</span>
</pre>
 * @author dca
 */
public interface Lambda<R, P> {
	/**
	 * Implementations take the parameter and return some return value.
	 * @param param The parameter.<br/>
	 * @return The return value.<br/>
	 * @throws IllegalArgumentException If param is null.<br/>
	 */
	public R apply(P param) throws IllegalArgumentException;
} // END interface Lambda
